import moment from 'moment';
//顶部tab信息
const orderTypeOptions1 = [
  { label: '自发订单', value: '0' },
  { label: '系统订单', value: '1' },
  { label: '售后订单', value: '3' },
  { label: '账期单号', value: '4' },
]

const orderTypeOptions2 = [
  { label: '系统订单', value: '1' },
  { label: '直发订单', value: '2' },
  { label: '售后订单', value: '3' },
]

//表单配置项
const formItemData = {
  'contractNo': {
    itemConfig: {
      name: 'time'
    },
    elConfig: {
      formType: 'rangTime',
      allowClear: false,
      placeholder: ['开始时间', '结束时间'],
      prefix: '时间',
      disabledDate: (current) => {
        return current && current > moment().endOf('day');
      },
      showTime: {
        defaultValue: [moment('00:00:00', 'HH:mm:ss'), moment('11:59:59', 'HH:mm:ss')],
      }
    }
  },
  'inputGroup': {
    formType: 'inputGroup',
    items: [
      {
        itemConfig: {
          name: 'costType'
        },
        elConfig: {
          formType: 'noLabelSelect',
          placeholder: '收支金额',
          options: [
            { label: '收入', value: '1' },
            { label: '支出', value: '2' },
          ],
          style: {
            width: '104px'
          }
        }
      },
      {
        itemConfig: {
          name: 'minAmount'
        },
        elConfig: {
          formType: 'InputNumber',
          precision: "2",
          min: 0.01,
          max: 9999999.99,
          placeholder: "金额",
          addonAfter: "元",
          style: {
            width: '150px'
          }
        }
      },
      {
        itemConfig: {
          name: ''
        },
        elConfig: {
          formType: 'IconFont',
          type: 'iconxiangyoujiaohuan',
          style: {
            fontSize: '20px',
            margin: '0 4px'
          }
        }
      },
      {
        itemConfig: {
          name: 'maxAmount'
        },
        elConfig: {
          formType: 'InputNumber',
          precision: "2",
          min: 0.01,
          max: 9999999.99,
          placeholder: "金额",
          addonAfter: "元",
          style: {
            width: '150px'
          }
        }
      },
    ],
  },
  'orderType': {
    itemConfig: {
      name: 'orderType'
    },
    elConfig: {
      formType: 'Select',
      placeholder: '订单类型',
    }
  },
  'billState': {
    itemConfig: {
      name: 'billState'
    },
    elConfig: {
      formType: 'Select',
      placeholder: '入账状态',
      options: [
        { label: '银行结算中', value: '0' },
        { label: '入账成功', value: '1' },
      ]
    }
  },
  'tradeNo': {
    itemConfig: {
      name: 'tradeNo'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '流水单号',
    }
  },
  'omsOrderSn': {
    itemConfig: {
      name: 'omsOrderSn'
    },
    elConfig: {
      formType: 'Input',
      placeholder: '系统单号',
    }
  },
}

//处理表单数据
export const getFormItem = (type) => {
  const arr = [];
  Object.keys(formItemData).map(v => {
    if (type == 1 && ['billState'].includes(v)) {
      return;
    }
    if (type == 2 && ['inputGroup', 'tradeNo', 'omsOrderSn'].includes(v)) {
      return;
    }
    if (v == 'orderType') {
      formItemData[v].elConfig.options = type == 1 ? orderTypeOptions1 : orderTypeOptions2;
    }
    arr.push(formItemData[v]);
  })
  return arr;
}